﻿#region Using namespaces

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

using BOL.Apps.GeneNetworkBrowser;

#endregion

namespace BOL.Apps.GeneNetworkBrowser.ViewModels
{
    public sealed class NetworksTreeViewItemViewModel : TreeViewItemViewModel
    {
        #region TreeViewItemViewModel implementation

        public ObservableCollection<Network> Networks { get; private set; }

        public NetworksTreeViewItemViewModel(IEnumerable<Network> networks, ProjectTreeViewItemViewModel vmProject)
            : base(vmProject, true)
        {
            Networks = new ObservableCollection<Network>(networks);
            _title = String.Format("Networks", networks.Count());
        }

        protected override void LoadChildren()
        {
            foreach (var network in Networks)
                base.Children.Add(new NetworkTreeViewItemViewModel(network, this));

            Children.Last().IsExpanded = true;
        }

        public void AddNetwork(Network network)
        {
            Networks.Add(network);
            base.Children.Add(new NetworkTreeViewItemViewModel(network, this));
        }

        #endregion
    }
}
